<?php
App::uses('AppController', 'Controller');
//App::uses('SessionComponent', 'Controller/Component');

class SzamlakControllerTest extends ControllerTestCase {
	
	public $fixtures = array('app.szamla', 'core.session');
	
	public function setUp() {
		parent::setUp();
		$this->Szamlak = $this->generate('Szamlak',
														 array(
															'components' => array('Session', 'DebugKit.Toolbar')
															)
														 );

		$this->controller->Session->expects($this->any())
			->method('read')
			->with($this->logicalOr('Settings.cegId', 'Settings.ev', 'Auth.User.id', 'Settings'))
			->will($this->returnCallback(
									function($param){
										if($param == 'Settings.cegId')
											return 2;
										elseif($param == 'Settings.ev')
											return 2012;
										elseif($param == 'Auth.User.id')
											return 1;
										elseif($param == 'Settings')
											return array('ev' => 2012, 'cegId' => 2);
										else
											return null;
									}
									));
	}

	public function testSearchWithoutReturnType(){
		$data = array('Bizonylat' => array(
													'_szamlatol' => 3831
													));
		$expected = 'li id="sz_9">3831';
		$actual = $this->testAction('/szamlak/search', array(
																				'return' => 'view',
																				'data' => $data,
																				'method' => 'post'));
		$this->assertContains($expected, $actual);
	}

	public function testSearchWithReturnTypeSzam(){
		$data = array('Bizonylat' => array(
													'_szamlatol' => 3831
													),
						  'rtn' => 'szam');
		$expected = 'li id="sz_3831">3831';
		$actual = $this->testAction('/szamlak/search', array(
																				'return' => 'view',
																				'data' => $data,
																				'method' => 'post'));
		$this->assertContains($expected, $actual);
	}
}
?>
